package com.hao.user.app.model.enums;

import com.hao.user.app.login.AccountLoginStrategy;
import com.hao.user.app.login.EmailLoginStrategy;
import com.hao.user.app.login.LoginStrategy;
import com.hao.user.app.login.PhoneLoginStrategy;

/**
 * @author haoge
 * @version 1.0
 * @date 2023/5/21 21:20
 */
public enum LoginTypeEnum {

    ACCOUNT(0,new AccountLoginStrategy()),
    PHONE(1,new PhoneLoginStrategy()),
    EMAIL(2,new EmailLoginStrategy());

    private int value;
    private LoginStrategy loginStrategy;

    LoginTypeEnum(int value, LoginStrategy loginStrategy) {
        this.value = value;
        this.loginStrategy = loginStrategy;
    }

    public static LoginTypeEnum getLoginTypeByValue(Integer value) {
        if (value == null) {
            return null;
        }
        LoginTypeEnum[] values = LoginTypeEnum.values();
        for (LoginTypeEnum loginTypeEnum : values) {
            if (loginTypeEnum.getValue() == value) {
                return loginTypeEnum;
            }
        }
        return null;
    }
    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public LoginStrategy getLoginStrategy() {
        return loginStrategy;
    }

    public void setLoginStrategy(LoginStrategy loginStrategy) {
        this.loginStrategy = loginStrategy;
    }
}
